﻿<Masa.Blazor.Presets.PSidebar @bind-Value="selectedKey"
                              Dense
                              Color="indigo"
                              Items="menus"
                              Title="m => m.Label"
                              Icon="m => m.Icon"
                              Key="m => m.Value"
                              Children="m => m.SubMenus"
                              TItem="Menu"
                              OnClick="Click">
</Masa.Blazor.Presets.PSidebar>

@code {

    static List<Menu> menus = new()
    {
        new Menu() { Label = "Home", Icon = "mdi-home", Value = "Home" },
        new Menu()
        {
            Label = "Users",
            Icon = "mdi-account-circle",
            Value = "Users",
            SubMenus = new List<Menu>()
            {
                new()
                {
                    Label = "Admin",
                    SubMenus = new List<Menu>()
                    {
                        new() { Label = "Management", Icon = "mdi-account-multiple-outline", Value = "Management" },
                        new() { Label = "Settings", Icon = "mdi-cog-outline", Value = "Settings" },
                    }
                },
                new()
                {
                    Label = "Actions",
                    SubMenus = new List<Menu>()
                    {
                        new() { Label = "Create", Icon = "mdi-plus-outline", Value = "Create" },
                        new() { Label = "Read", Icon = "mdi-file-outline", Value = "Read" },
                        new() { Label = "Update", Icon = "mdi-update", Value = "Update" },
                        new() { Label = "Delete", Icon = "mdi-delete", Value = "Delete" },
                    }
                },
            }
        },
    };

    StringNumber selectedKey = "Management";

    void Click(Menu item)
    {
    // code with clicked item
    }

    class Menu
    {
        public string Label { get; set; }

        public string Value { get; set; }

        public string Icon { get; set; }

        public List<Menu> SubMenus { get; set; }
    }

}